package com.yanqu.road.server.cmd.monopolymarket.fortress;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.pb.monopolymarket.MonopolyMarketProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * @Description
 * @Author cwq
 * @Data 2021/10/15 16:32
 */
@Cmd(code = GameProtocol.S_MONOPOLY_MARKET_FORTRESS_RECEIVE_RANK_REWARD_FROM_CROSS, desc = "边关要塞 领取排行奖励 跨服返回区服 协议")
public class MonopolyMarketFortressRankRewardRewardFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        MonopolyMarketProto.MonopolyMarketFortressRankReceiveRewardRespMsg stcMsg = MonopolyMarketProto.MonopolyMarketFortressRankReceiveRewardRespMsg.parseFrom(packet.getBytes());
        if(stcMsg.getRet() == 0){
            Property reward = PropertyHelper.parseStringToProperty(stcMsg.getReward());
            player.getModule(CurrencyModule.class).addCurrency(reward, eLogMoneyType.MonopolyMarket,eLogMoneyType.MonopolyMarketFortressReceiveRankReward);
        }
        player.sendPacket(ClientProtocol.U_MONOPOLY_MARKET_FORTRESS_RANK_RECEIVE_REWARD, stcMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
    }

}
